package proyectoFC_2_3_3.koyicabuto;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.view.MotionEvent;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class OverlayMapa extends Overlay {
	
    private Double latitud = null;
    private Double longitud = null;
    
    public OverlayMapa(Double latitud, Double longitud){
    	this.latitud = latitud;
    	this.longitud = longitud;
    }
 
    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow){
        
    	Projection projection = mapView.getProjection();
        
        GeoPoint geoPoint = new GeoPoint(latitud.intValue(), longitud.intValue());
 
        if (shadow == false){
            Point centro = new Point();
            projection.toPixels(geoPoint, centro);
            
            Bitmap bitmap = BitmapFactory.decodeResource(mapView.getResources(), R.drawable.icono_flecha_abajo);
			canvas.drawBitmap(bitmap, centro.x+10, centro.y+5, null);
        }
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent event, MapView mapView){   
        if (event.getAction() == 1) {                
            Toast.makeText(mapView.getContext(), "Lo coje", Toast.LENGTH_SHORT).show();
        }                            
        return false;
    } 
}
